package com.ms.education.acl.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.ms.education.acl.mapper.PermissionMapper;
import com.ms.education.acl.mapper.RoleMapper;
import com.ms.education.acl.service.SaTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>Project:education-SaTokenController
 * <p>Powered by ms on 2023-03-12 14:45:20
 *
 * @author ms
 * @version 1.0
 * @since 1.8
 */
@RestController
@RequestMapping("/acl/sa-token")
public class SaTokenController {

    @Autowired
    private SaTokenService saTokenService;

    @SaCheckLogin
    @GetMapping("getUserRoles/{userId}")
    public List<String> getUserRoles(@PathVariable("userId") Integer userId) {
        return saTokenService.getUserRoles(userId);
    }

    @SaCheckLogin
    @GetMapping("getUserPermissions/{userId}")
    public List<String> getUserPermissions(@PathVariable("userId") Integer userId) {
        return saTokenService.getUserPermissions(userId);
    }

    @SaCheckLogin
    @GetMapping("getPermissionByRoleName/{roleName}")
    public List<String> getPermissionByRoleName(@PathVariable("roleName") String roleName) {
        return saTokenService.getPermissionByRoleName(roleName);
    }


}
